<!DOCTYPE html>
<html lang='en'>

<head>
    <meta charset='UTF-8'>
    <meta http-equiv='X-UA-Compatible' content='IE=edge'>
    <meta name='viewport' content='width=device-width, initial-scale=1.0'>
    <title>Document</title>
    <script src='../vue.global.js'></script>
</head>

<body>
    <div id="app">
        <!-- 在“change”时而非“input”时更新 -->
        <!-- change事件只有按下回车或input失去焦点时才会触发 -->
        lazy <input v-model.lazy="msg" />
        <br>

        <!-- 对用户的输入去除头尾空格 -->
        trim <input v-model.trim="msg" />
        <br>

        <span>{{msg}}</span>
        <span>{{msgLen}}</span>
        <br>

        number <input v-model.number="age" type="text" />
        <span>{{ age }}</span>
        <span>{{ ageType }}</span>
    </div>

    <script>
        const app = Vue.createApp({
            data() {
                return {
                    msg: "yes",
                    age: 18
                }
            },
            computed: {
                ageType() {
                    return typeof this.age
                },
                msgLen(){
                    return this.msg.length
                }
            }
        })
        const vm = app.mount('#app')
    </script>
</body>

</html>